home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 1 / PCU0103CD1.iso / entertn / demos / files / aomtrial.exe / AOM / AI / SCN04P5.XS < prev    next >
Encoding:
Text File  |  2002-08-30  |  7.0 KB  |  209 lines

  1. //==============================================================================
  2. // Scn04p5: AI Scenario Script for scenario 4 player 5
  3. //==============================================================================
  4. /*
  5.    AI owner:  Dave Leary
  6.    Scenario owner: Dave Leary
  7.  
  8.     This AI is based on scn04p2.xs, and is used to handle the final "big attack"
  9.     in scenario 4.  See scn04p2 for difficulty level details.
  10.  
  11. */
  12. //==============================================================================
  13. // Set Town Location
  14. //==============================================================================
  15. void setTownLocation(void)
  16. {
  17.    //Look for the "Town Location" marker.
  18.    kbSetTownLocation(kbGetBlockPosition("3539"));
  19. }
  20.  
  21. //==============================================================================
  22. // miscStartup
  23. //==============================================================================
  24. void miscStartup(void)
  25. {
  26.     // Difficulty Level check.
  27.     int difflevel=-1;        
  28.     difflevel=aiGetWorldDifficulty();
  29.  
  30.    //Startup message(s).
  31.    aiEcho("");
  32.    aiEcho("");
  33.    aiEcho("Scn04P2 AI Start, filename='"+cFilename+"'.");
  34.     aiEcho("Difficulty Level="+difflevel+".");
  35.    //Spit out the map size.
  36.    aiEcho("  Map size is ("+kbGetMapXSize()+", "+kbGetMapZSize()+").");
  37.    //Cheat like a bastard.  Once only, though.
  38.    kbLookAtAllUnitsOnMap();
  39.    //Calculate some areas.
  40.    kbAreaCalculate(1200.0);
  41.    //Set our town location.
  42.    setTownLocation();
  43.     //Reset random seed
  44.     aiRandSetSeed();
  45.    //Allocate all resources to the root escrow.
  46.    kbEscrowAllocateCurrentResources();
  47. }
  48.  
  49. //==============================================================================
  50. //==============================================================================
  51. // Attack stuff.
  52. //==============================================================================
  53. //==============================================================================
  54. //Shared variables.
  55.  
  56. int attackerUnitTypeIDSoldier=cUnitTypeAxeman;
  57. int attackerUnitTypeIDTransport=cUnitTypePirateShip;
  58.  
  59. //=========================================================================================
  60. // Kidd's cool configQuery function: used to create attack routes, etc.  Oooh, lovin' that!
  61. //=========================================================================================
  62. bool configQuery( int queryID = -1, int unitType = -1, int action = -1, int state = -1, int player = -1, vector center = vector(-1,-1,-1), bool sort = false, float radius = -1 )
  63. {
  64.    if ( queryID == -1)
  65.    {
  66.       return(false);
  67.    }
  68.  
  69.    if (player != -1)
  70.       kbUnitQuerySetPlayerID(queryID, player);
  71.    
  72.    if (unitType != -1)
  73.       kbUnitQuerySetUnitType(queryID, unitType);
  74.  
  75.    if (action != -1)
  76.       kbUnitQuerySetActionType(queryID, action);
  77.  
  78.    if (state != -1)
  79.       kbUnitQuerySetState(queryID, state);
  80.  
  81.    if (center != vector(-1,-1,-1))
  82.    {
  83.       kbUnitQuerySetPosition(queryID, center);
  84.       if (sort == true)
  85.          kbUnitQuerySetAscendingSort(queryID, true);
  86.       if (radius != -1)
  87.          kbUnitQuerySetMaximumDistance(queryID, radius);
  88.    }
  89.    return(true);
  90. }
  91.  
  92. //=====================================================================================
  93. // finalAttack.  This is called from the scenario with an AI Func effect
  94. //=====================================================================================
  95. void finalAttack(int whichAttack = -1)
  96. {
  97.     int transportPlanID=aiPlanCreate("Transport Group", cPlanTransport);
  98.     // "whichTransport" adds a specific transport to the plans.  Victory conditions, chats, etc.
  99.     // are tied to the concept of the main transport getting whacked.
  100.     int whichTransport=-1;
  101.  
  102.     // Difficulty Level check.
  103.     int difflevel=-1;        
  104.     difflevel=aiGetWorldDifficulty();
  105.  
  106.     vector gatherPoint=kbGetBlockPosition("3535");
  107.     vector targetPoint=kbGetBlockPosition("2642");
  108.     vector initialPosition=kbGetBlockPosition("3539");
  109.  
  110.     int baseID = kbBaseCreate( 5, "mainBase", initialPosition, 50.0);
  111.     
  112.     // Same unit types in each transport.
  113.     aiPlanAddUnitType(transportPlanID, cUnitTypePirateShip, 1, 1, 1);
  114.     aiPlanAddUnitType(transportPlanID, cUnitTypeSpearman, 8, 8, 8);
  115.     aiPlanAddUnitType(transportPlanID, cUnitTypeAnubite, 2, 2, 2);
  116.     
  117.     if (transportPlanID >= 0)
  118.    {
  119.         aiEcho("*** BOAT FROM FINAL ATTACK EN ROUTE ***");
  120.         switch(whichAttack)
  121.         {    
  122.             case 0:
  123.             {
  124.                 gatherPoint=kbGetBlockPosition("3535");
  125.                 targetPoint=kbGetBlockPosition("3541");
  126.  
  127.                 whichTransport = kbGetBlockID("3531");
  128.  
  129.                 aiPlanSetVariableInt(transportPlanID, cTransportPlanTransportTypeID, 0, cUnitTypePirateShip);
  130.                 aiPlanSetVariableInt(transportPlanID, cTransportPlanTransportID, 0, whichTransport);
  131.                 break;
  132.             }
  133.  
  134.             case 1:
  135.             {
  136.                 
  137.                 gatherPoint=kbGetBlockPosition("3536");
  138.                 targetPoint=kbGetBlockPosition("3540");
  139.  
  140.                 whichTransport = kbGetBlockID("3532");
  141.  
  142.                 aiPlanSetVariableInt(transportPlanID, cTransportPlanTransportTypeID, 0, cUnitTypePirateShip);
  143.                 aiPlanSetVariableInt(transportPlanID, cTransportPlanTransportID, 0, whichTransport);
  144.                 break;
  145.             }
  146.  
  147.             case 2:
  148.             {
  149.                 gatherPoint=kbGetBlockPosition("3537");
  150.                 targetPoint=kbGetBlockPosition("3542");
  151.  
  152.                 whichTransport = kbGetBlockID("3533");
  153.  
  154.                 aiPlanSetVariableInt(transportPlanID, cTransportPlanTransportTypeID, 0, cUnitTypePirateShip);
  155.                 aiPlanSetVariableInt(transportPlanID, cTransportPlanTransportID, 0, whichTransport);
  156.                 break;
  157.             }
  158.  
  159.             case 3:
  160.             {
  161.                 gatherPoint=kbGetBlockPosition("3538");
  162.                 targetPoint=kbGetBlockPosition("3543");
  163.  
  164.                 whichTransport = kbGetBlockID("3534");
  165.                 
  166.                 aiPlanSetVariableInt(transportPlanID, cTransportPlanTransportTypeID, 0, cUnitTypePirateShip);
  167.                 aiPlanSetVariableInt(transportPlanID, cTransportPlanTransportID, 0, whichTransport);
  168.                 break;
  169.             }
  170.         }
  171.  
  172.         aiPlanSetVariableBool(transportPlanID, cTransportPlanMaximizeXportMovement, 0, true);
  173.         aiPlanSetVariableVector(transportPlanID, cTransportPlanGatherPoint, 0, gatherPoint);
  174.       aiPlanSetVariableVector(transportPlanID, cTransportPlanTargetPoint, 0, targetPoint);
  175.  
  176.         // Setting the base.
  177.         aiPlanSetBaseID( transportPlanID, baseID );
  178.  
  179.         // Don't return when finished.
  180.         aiPlanSetVariableBool(transportPlanID, cTransportPlanReturnWhenDone, 0, false);
  181.  
  182.         // Initial Position
  183.         aiPlanSetInitialPosition( transportPlanID, initialPosition );
  184.             
  185.         aiPlanAddUnit(transportPlanID, whichTransport);
  186.       aiPlanSetActive(transportPlanID);
  187.    }
  188. }
  189.  
  190.  
  191. //=====================================================================================
  192. // responseRangeSet
  193. //=====================================================================================
  194. void responseRangeSet(int parameter = -1)
  195. {
  196.     // Drop the AI attack response distance to hopefully get guys running
  197.     // away bett4r.
  198.     aiSetAttackResponseDistance(0.0);
  199. }
  200.  
  201. //==============================================================================
  202. // MAIN.
  203. //==============================================================================
  204. void main(void)
  205. {
  206.    //Startup.
  207.    miscStartup();
  208. }
  209.